/**
 * Created by guoshuyu on 2017/11/8.
 */

import * as Config from '../../config/Config'

const isPro = Object.is(process.env.NODE_ENV, 'production')
let host = 'http://user.test.yarsenal.com/app/'
// let host = isPro ? 'http://user.test.yarsenal.com/app/' : '/trend/'
const AddressLocal = {
  /**
   * 获取授权  post
   */
  getAuthorization: () => {
    return `${host}auth/login`
  },
  /**
   * 用户信息 get
   */
  getUserInfo: () => {
    return `${host}auth/profile`
  },
  /**
   * 用户注册
   * @returns {string}
   */
  doRegister: () => {
    return `${host}auth/register`
  },
  /**
   * 重置密码
   * @returns {string}
   */
  doRest: () => {
    return `${host}auth/reset-password`
  },
  /**
   * 发送验证码 post
   */
  sendCode: () => {
    return `${host}auth/send-code`
  },
  /**
   * 获取广告图片
   */
  getPictures: (column, limit) => {
    return `${host}content-picture?column=${column}&limit=${limit}`
  },
  /**
   * 产品展示 get
   */
  getEventReceived: () => {
    return `${host}product`
  },
  /**
   * 获取产品详情
   */
  getProductDesc: (id) => {
    return `${host}product/${id}`
  },
  /**
   * 确认订单商品
   */
  placeOrder: () => {
    return `${host}place-order`
  },
  /**
   * 订单部分
   */
  order: () => {
    return `${host}order`
  },
  /**
   * 取消订单
   */
  cancelOrder: (id) => {
    return `${host}cancel-order/${id}`
  },
  /**
   * 用户今日分钟数
   */
  getUserDayMinute: () => {
    return `${host}user/day-minute`
  },
  /**
   * 用户当月分钟数
   */
  getUserMonthMinute: () => {
    return `${host}user/month-minute`
  },
  /**
   * 用户总分钟数
   */
  getUserTotalMinute: () => {
    return `${host}user/total-minute`
  },
  /**
   * 课程时间轴
   */
  getUserLessonsTimeAxis: () => {
    return `${host}user/lessons`
  },
  /**
   * 获取下一节课
   * @returns {string}
   */
  getUserNextLesson: () => {
    return `${host}user/lesson`
  },
  /**
   * 文章
   * @param since daily，weekly， monthly
   */
  getContentBolg: () => {
    return `${host}content-blog`
  },
  /**
   * 用户课程
   * @returns {string}
   */
  getUserCourse: () => {
    return `${host}course`
  },
  /**
   * 用户测评
   * @returns {string}
   */
  getUserTest: () => {
    return `${host}evaluation`
  },
  /**
   * 获取答题进度
   * @param id
   */
  getAnswer: (id) => {
    return `${host}evaluation/${id}/answers`
  },

  /**
   * 获取测评结果
   * @param type
   */
  getEvaluationResult: (user,test) => {
    return `${host}evaluation/result/${user}/${test}`
  },

  /**
   * 保存答案
   * @returns {string}
   */
  saveAnswers: () => {
    return `${host}evaluation/save-answers`
  },
  /**
   * 用户作业
   * @returns {string}
   */
  getUserTask: () => {
    return `${host}task`
  },
  /**
   * 修改用户信息
   */
  updateUserName: () => {
    return `${host}user/update-name`
  },
  /**
   * 修改手机号
   * @returns {string}
   */
  updateUserMobile: () => {
    return `${host}user/update-mobile`
  },

  /**
   * 查询
   */
  searchList: (keyword) => {
    return `${host}search-list?keyword=${keyword}`
  },
  /**
   * 处理分页参数
   * @param tab 表示是 ? 或者 &
   * @param page 页数
   * @param pageSize 每页数量
   */
  getPageParams: (tab, page, pageSize = Config.PAGE_SIZE) => {
    if (page !== null) {
      if (pageSize !== null) {
        return `${tab}page=${page}&per_page=${pageSize}`
      } else {
        return `${tab}page=${page}`
      }
    } else {
      return ''
    }
  },
}

export default AddressLocal
